package com.panda.mall.product.house.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.panda.mall.common.mallCoupon.dto.CouponInfoDto;
import com.panda.mall.common.mallProduct.dto.ProductHouseDto;
import com.panda.mall.common.mallProduct.entity.MallProductHouse;
import com.panda.mall.common.result.Result;
import com.panda.mall.product.house.service.MallProductHouseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * author: tcy
 * createDate: 2023/7/19
 * description: 仓库信息接口
 */
@Api(tags = "仓库信息")
@RestController
@RequestMapping("/product/house")
public class MallProductHouseController {

    @Autowired
    MallProductHouseService mallProductHouseService;

    @ApiOperation(value = "条件分页查询", notes = "仓库信息")
    @PostMapping("/pageList")
    public Result<Page<MallProductHouse>> pageList(@RequestBody ProductHouseDto productHouseDto){
        return Result.success(mallProductHouseService.pageList(productHouseDto));
    }

    @ApiOperation(value = "新增或保存", notes = "仓库信息")
    @PostMapping("/saveOrUpdateHouse")
    public Result<Boolean> saveOrUpdateHouse(@RequestBody MallProductHouse house){
        return Result.success(mallProductHouseService.saveOrUpdateHouse(house));
    }

    @ApiOperation(value = "仓库详情", notes = "仓库信息")
    @GetMapping("/detail/{id}")
    public Result<MallProductHouse> detail(@PathVariable("id") Long id){
        return Result.success(mallProductHouseService.detail(id));
    }

    @ApiOperation(value = "删除仓库", notes = "仓库信息")
    @PostMapping("/delete")
    public Result<Boolean> delete(@RequestBody List<Long> ids){
        return Result.success(mallProductHouseService.delete(ids));
    }
}
